package spe.ui.editor.command;

import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.tools.CellEditorLocator;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Text;

public class ElementCellEditorLocator implements CellEditorLocator 
{
	private Label label;

	public ElementCellEditorLocator(Label lb)
	{
		label = lb;
	}
	
	@Override
	public void relocate(CellEditor celleditor) 
	{
		Text txt = (Text)celleditor.getControl();
		Point pref = txt.computeSize(SWT.DEFAULT, SWT.DEFAULT);
		Rectangle rect = label.getTextBounds().getCopy();
		label.translateToAbsolute(rect);
		txt.setBounds(rect.x - 5, rect.y - 2, pref.x + 5, pref.y + 2);
	}

}
